/**
 * 
 */
package com.gmail.blackdog1987.onedollar.service.impl;

import com.gmail.blackdog1987.onedollar.dao.*;
import com.gmail.blackdog1987.onedollar.entity.*;
import com.gmail.blackdog1987.onedollar.entity.base.Page;
import com.gmail.blackdog1987.onedollar.service.GoodsService;
import com.gmail.blackdog1987.onedollar.util.ErrorCode;
import com.gmail.blackdog1987.onedollar.util.JsonChangeUtil;
import com.gmail.blackdog1987.onedollar.vo.GoodsJudgeVO;
import com.gmail.blackdog1987.onedollar.vo.GoodsOneDollarVO;
import com.gmail.blackdog1987.onedollar.vo.GoodsOneDollarWinnerVO;
import com.gmail.blackdog1987.onedollar.vo.GoodsShowVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.sql.Timestamp;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * 
 * @author 董国超
 *
 */
@Service("goodsService")
public class GoodsServiceImpl implements GoodsService {
	
	@Autowired
	private OneDorllarGoodsDao oneDorllarGoodsDao;
	@Autowired
	private GoodsShowDao goodsShowDao;
	@Autowired
	private GoodsDao goodsDao;
	@Autowired
	private OneDorllarWinnerDao oneDorllarWinnerDao;
	@Autowired
	private GoodsPictureDao goodsPictureDao;
	@Autowired
	private GoodsPriceDao goodsPriceDao;
	@Autowired
	private GoodsJudgeDao goodsJudgeDao;
	@Autowired
	private UserDao userDao;
	@Autowired
	private OrderOneDollarDao orderOneDollarDao;
	@Autowired
	private OrderDao orderDao;
	@Autowired
	private OrderGoodsDao orderGoodsDao;
	@Autowired
	private GoodsCatDao goodsCatDao;
	@Autowired
	private OrderOneDollarUserDao orderOneDollarUserDao;
	@Autowired
	private GoodsShowLikeDao goodsShowLikeDao;
	@Autowired
	private GoodsShowCommentDao goodsShowCommentDao;
	@Autowired
	private SearchKeywordDao searchKeywordDao;
	@Override
	public Map<String, Object> getOneDollarList(Map<String, String> filter, int type) {
		ResultJson resultJson = JsonChangeUtil.setResultJson("0000", "请求成功");

		String pageIndex = filter.get("pageindex");
		String pageSize = filter.get("pagesize");
		String keyword = filter.get("keyword");
		String sort = filter.get("sort");
		String category = filter.get("category");
		String isMain = filter.get("type");

		int index = 1;
		int size = 10;
		if(pageIndex!=null&&pageIndex.length()!=0){
			index = Integer.valueOf(pageIndex);
			if(index<1){
				index = 1;
			}
		}
		if(pageSize!=null&&pageSize.length()!=0){
			size = Integer.valueOf(pageSize);
			if(size==0){
				size = 10;
			}
		}

		int sortValue = 0;
		if(sort == null||sort.length()==0){

		}else{
			sortValue = Integer.valueOf(sort);
		}

		Page page;
		if(isMain!=null&&isMain.equals("1")){
			page = oneDorllarGoodsDao.queryForPage(index, size, 5, category, type);
		}else{
			page = oneDorllarGoodsDao.queryForPage(index, size, sortValue, category, type);
		}

		resultJson.put("data", page);

		return resultJson.getResultMap();
	}

	@Override
	public Map<String, Object> getNewOneDollarList(Map<String, String> filter) {
		ResultJson resultJson = JsonChangeUtil.setResultJson("0000", "请求成功");

		String pageIndex = filter.get("pageindex");
		String pageSize = filter.get("pagesize");
		String type = filter.get("type");

		int index = 1;
		int size = 10;
		if(pageIndex!=null&&pageIndex.length()!=0){
			index = Integer.valueOf(pageIndex);
			if(index<1){
				index = 1;
			}
		}
		if(pageSize!=null&&pageSize.length()!=0){
			size = Integer.valueOf(pageSize);
			if(size==0){
				size = 10;
			}
		}

		if(type==null||type.isEmpty()){
			type = "0";
		}

		Page page = oneDorllarGoodsDao.queryForPage(index, size, 5, "-1", Integer.valueOf(type));

		resultJson.put("data", page);

		return resultJson.getResultMap();
	}

	@Override
	public Map<String, Object> getPresentOneDollarList(Map<String, String> filter) {
		ResultJson resultJson = JsonChangeUtil.setResultJson("0000", "请求成功");

		String pageIndex = filter.get("pageindex");
		String pageSize = filter.get("pagesize");
		String type = filter.get("type");

		int index = 1;
		int size = 10;
		if(pageIndex!=null&&pageIndex.length()!=0){
			index = Integer.valueOf(pageIndex);
			if(index<1){
				index = 1;
			}
		}
		if(pageSize!=null&&pageSize.length()!=0){
			size = Integer.valueOf(pageSize);
			if(size==0){
				size = 10;
			}
		}

		if(type==null||type.isEmpty()){
			type = "0";
		}

		Page page = oneDorllarGoodsDao.queryForPage(index, size, 0, "-1", Integer.valueOf(type));

		resultJson.put("data", page);
		return resultJson.getResultMap();
	}

	@Override
	public Map<String, Object> getOneDollarWin(Map<String, String> filter) {
		ResultJson resultJson = JsonChangeUtil.setResultJson("0000", "请求成功");

		String pageIndex = filter.get("pageindex");
		String pageSize = filter.get("pagesize");
		String type = filter.get("type");
		String userid = filter.get("userid");

		int index = 1;
		int size = 10;
		if(pageIndex!=null&&pageIndex.length()!=0){
			index = Integer.valueOf(pageIndex);
			if(index<1){
				index = 1;
			}
		}
		if(pageSize!=null&&pageSize.length()!=0){
			size = Integer.valueOf(pageSize);
			if(size==0){
				size = 10;
			}
		}

		if(type==null||type.isEmpty()){
			type = "0";
		}

		Page page = oneDorllarGoodsDao.queryForWin(Integer.valueOf(userid), index, size, Integer.valueOf(type));

		resultJson.put("data", page);

		return resultJson.getResultMap();
	}

	@Override
	public Map<String, Object> getOneDollarHistory(Map<String, String> filter) {
		ResultJson resultJson = JsonChangeUtil.setResultJson("0000", "请求成功");

		String pageIndex = filter.get("pageindex");
		String pageSize = filter.get("pagesize");
		String type = filter.get("type");
		String goodsid = filter.get("goodsid");

		int index = 1;
		int size = 10;
		if(pageIndex!=null&&pageIndex.length()!=0){
			index = Integer.valueOf(pageIndex);
			if(index<1){
				index = 1;
			}
		}
		if(pageSize!=null&&pageSize.length()!=0){
			size = Integer.valueOf(pageSize);
			if(size==0){
				size = 10;
			}
		}

		Page page = oneDorllarGoodsDao.queryForPageByGoodsId(index, size, Integer.valueOf(goodsid), Integer.valueOf(type));

		resultJson.put("data", page);

		return resultJson.getResultMap();
	}

	@Override
	public Map<String, Object> getShow(Map<String, String> filter) {
		String id = filter.get("id");
		String userid = filter.get("userid");

		GoodsShowVO vo = goodsShowDao.query(Integer.valueOf(id), Integer.valueOf(userid));

		return JsonChangeUtil.setResultJson(vo).getResultMap();
	}

	@Override
	public Map<String, Object> getKeywords(Map<String, String> filter) {
		return JsonChangeUtil.setResultJSONList(searchKeywordDao.query()).getResultMap();
	}

	@Override
	public Map<String, Object> getMyOneDollarList(Map<String, String> filter, int type) {

		ResultJson resultJson = JsonChangeUtil.setResultJson("0000", "请求成功");

		String pageIndex = filter.get("pageindex");
		String pageSize = filter.get("pagesize");
		String userid = filter.get("userid");
		String status = filter.get("status");

		int index = 1;
		int size = 10;
		if(pageIndex!=null&&pageIndex.length()!=0){
			index = Integer.valueOf(pageIndex);
			if(index<1){
				index = 1;
			}
		}
		if(pageSize!=null&&pageSize.length()!=0){
			size = Integer.valueOf(pageSize);
			if(size==0){
				size = 10;
			}
		}

		Page page = oneDorllarGoodsDao.queryMyOneForPage(index, size, Integer.valueOf(userid), type, status);


		resultJson.put("data", page);

		return resultJson.getResultMap();
	}

	@Override
	public Map<String, Object> getOneDollarDetail(Map<String, String> filter) {
		ResultJson resultJson = JsonChangeUtil.setResultJson("0000", "请求成功");

		String userid = filter.get("userid");
		String onedollarid = filter.get("onedollarid");

		// GoodsOneDollarVO
		GoodsOneDollarVO goods = oneDorllarGoodsDao.query(Integer.valueOf(userid==null||userid.length()==0?"0":userid), Integer.valueOf(onedollarid));

		Map<String, Object> param = new HashMap<String, Object>();
		param.put("userId", Integer.valueOf(userid));
		param.put("payStatus", 1);
		param.put("onedollarId", Integer.valueOf(onedollarid));
		Map<String, Object> sortParam = new HashMap<String, Object>();
		sortParam.put("randomCode", "asc");
		List<TOrderOnedollarEntity> orders = orderOneDollarDao.find(param, sortParam);
		List<GoodsOneDollarWinnerVO> tickets = oneDorllarWinnerDao.query(onedollarid);

		List<TGoodsPictureEntity> pics = goodsPictureDao.findBy("goodsId", goods.getGoodsId());

		Map<String, Object> result = new HashMap<String, Object>();
		result.put("goods", goods);
		result.put("imgs", pics);
		result.put("orders", orders);
		result.put("tickets", tickets);

		resultJson.put("data", result);

		return resultJson.getResultMap();
	}

	@Override
	public Map<String, Object> getOneDollarWinner(Map<String, String> filter) {
		ResultJson resultJson = JsonChangeUtil.setResultJson("0000", "请求成功");

		String onedollarid = filter.get("onedollarid");
		List<GoodsOneDollarWinnerVO> winner = oneDorllarWinnerDao.query(onedollarid);
		resultJson.put("data", winner);
		return resultJson.getResultMap();
	}

	@Override
	public Map<String, Object> getShowList(Map<String, String> filter) {
		ResultJson resultJson = JsonChangeUtil.setResultJson("0000", "请求成功");

		String pageIndex = filter.get("pageindex");
		String pageSize = filter.get("pagesize");
		String userid = filter.get("userid");
		String sort = filter.get("sort");
		String type = filter.get("type");

		int index = 1;
		int size = 10;
		if(pageIndex!=null&&pageIndex.length()!=0){
			index = Integer.valueOf(pageIndex);
			if(index<1){
				index = 1;
			}
		}
		if(pageSize!=null&&pageSize.length()!=0){
			size = Integer.valueOf(pageSize);
			if(size==0){
				size = 10;
			}
		}

		if(type==null||type.isEmpty()){
			type = "0";
		}

		int sortValue = 0;
		if(sort!=null&&!sort.isEmpty()){
			sortValue = Integer.valueOf(sort);
		}

		Page page;
		if(userid==null||userid.length()==0){
			page = goodsShowDao.queryForPage(index, size, sortValue);
		}else{
			page = goodsShowDao.queryForPage(index, size, Integer.valueOf(userid), sortValue, Integer.valueOf(type));
		}

		resultJson.put("data", page);

		return resultJson.getResultMap();
	}

	@Override
	public Map<String, Object> getGoodsList(Map<String, String> filter) {
		ResultJson resultJson = JsonChangeUtil.setResultJson("0000", "请求成功");

		String pageIndex = filter.get("pageindex");
		String pageSize = filter.get("pagesize");
		String category = filter.get("category");
		String keyword = filter.get("keyword");
		String sort = filter.get("sort");		// 销量0，价格1
		String orderby = filter.get("orderby");		// 升0，降1

		int index = 1;
		int size = 10;
		if(pageIndex!=null&&pageIndex.length()!=0){
			index = Integer.valueOf(pageIndex);
			if(index<1){
				index = 1;
			}
		}
		if(pageSize!=null&&pageSize.length()!=0){
			size = Integer.valueOf(pageSize);
			if(size==0){
				size = 10;
			}
		}

		if(sort==null||sort.length()==0){
			sort = "0";
		}
		if(orderby==null||orderby.length()==0){
			orderby = "1";
		}

		Page page;
		if(category==null||category.length()==0){
			page = goodsDao.queryForPage(index, size, sort, orderby, keyword);
		}else{
			page = goodsDao.queryForPage(index, size, Integer.valueOf(category), sort, orderby, keyword);
		}

		resultJson.put("data", page);

		return resultJson.getResultMap();
	}

	@Override
	public Map<String, Object> getMyGoodsList(Map<String, String> filter) {
		ResultJson resultJson = JsonChangeUtil.setResultJson("0000", "请求成功");

		String pageIndex = filter.get("pageindex");
		String pageSize = filter.get("pagesize");
		String userid = filter.get("userid");

		int index = 1;
		int size = 10;
		if(pageIndex!=null&&pageIndex.length()!=0){
			index = Integer.valueOf(pageIndex);
			if(index<1){
				index = 1;
			}
		}
		if(pageSize!=null&&pageSize.length()!=0){
			size = Integer.valueOf(pageSize);
			if(size==0){
				size = 10;
			}
		}

		Page page = goodsDao.queryForPageByUserId(index, size, Integer.valueOf(userid));

		resultJson.put("data", page);

		return resultJson.getResultMap();
	}

	@Override
	public Map<String, Object> getCommentList(Map<String, String> filter) {
		ResultJson resultJson = JsonChangeUtil.setResultJson("0000", "请求成功");

		String pageIndex = filter.get("pageindex");
		String pageSize = filter.get("pagesize");
		String goodsid = filter.get("goodsid");

		int index = 1;
		int size = 10;
		if(pageIndex!=null&&pageIndex.length()!=0){
			index = Integer.valueOf(pageIndex);
			if(index<1){
				index = 1;
			}
		}
		if(pageSize!=null&&pageSize.length()!=0){
			size = Integer.valueOf(pageSize);
			if(size==0){
				size = 10;
			}
		}

		Page page = goodsJudgeDao.queryForPage(index, size, Integer.valueOf(goodsid));
		resultJson.put("data", page);

		return resultJson.getResultMap();
	}

	@Override
	public Map<String, Object> getGoodsDetail(Map<String, String> filter) {
		ResultJson resultJson = JsonChangeUtil.setResultJson("0000", "请求成功");

		String goodsid = filter.get("goodsid");

		TGoodsEntity goods = goodsDao.get(Integer.valueOf(goodsid));
		List<TGoodsParamEntity> params = goodsDao.queryParams(Integer.valueOf(goodsid));
		List<TParamGroupEntity> paramsValues = goodsDao.queryParamsValues(Integer.valueOf(goodsid));
		List<GoodsJudgeVO> comments = goodsDao.queryComments(Integer.valueOf(goodsid), 3);
		List<TGoodsPictureEntity> img = goodsPictureDao.findBy("goodsId", Integer.valueOf(goodsid));
		List<TGoodsPriceEntity> price = goodsPriceDao.findBy("goodsId", Integer.valueOf(goodsid));

		Map resultMap = new HashMap();
		resultMap.put("goods", goods);	// 商品
		resultMap.put("imgs", img);		// 商品图片
		resultMap.put("params", params);		// 商品可选的参数
		resultMap.put("price", price);			// 商品的价格（根据不同的参数有不同的价格）
		resultMap.put("paramsValues", paramsValues);		// 可选参数的值
		resultMap.put("comments", comments);				// 评论
		resultJson.put("data", resultMap);

		return resultJson.getResultMap();
	}

	@Override
	public Map<String, Object> doAddShow(Map<String, String> filter) {
		ResultJson resultJson = JsonChangeUtil.setResultJson("0000", "请求成功");

		String userid = filter.get("userid");
		String goodsid = filter.get("goodsid");
		String onedollarid = filter.get("onedollarid");
		String orderid = filter.get("orderid");
		String content = filter.get("content");
		String imgs = filter.get("imgs");

		TUserEntity user = userDao.get(Integer.valueOf(userid));
		if(user==null){
			return JsonChangeUtil.setResultJson(ErrorCode.NOTAUTHORIZED, "您不能这样做！").getResultMap();
		}
		TGoodsShowEntity showEntity = new TGoodsShowEntity();
		showEntity.setUserId(user.getUserId());
		showEntity.setCreatetime(new Timestamp(System.currentTimeMillis()));
		if((content==null||content.length()==0)&&(imgs==null||imgs.length()==0)){
			return JsonChangeUtil.setResultJson(ErrorCode.NOTAUTHORIZED, "您什么也没有提交！").getResultMap();
		}
		if(content==null||content.length()==0){
			showEntity.setContent("这个用户很懒，什么也没留下...");
		}else{
			showEntity.setContent(content);
		}
		if(imgs!=null&&imgs.length()!=0){
			showEntity.setImgs(imgs);
		}

		if(orderid==null||orderid.isEmpty()){
			return JsonChangeUtil.setResultJson(ErrorCode.NOTAUTHORIZED, "你都没有下单，不能晒单哦！").getResultMap();
		}

		if(onedollarid!=null&&onedollarid.length()!=0){		// 一元/十元的晒单
			TGoodsOnedollarEntity onedollarEntity = oneDorllarGoodsDao.get(Integer.valueOf(onedollarid));
			if(onedollarEntity!=null){
				showEntity.setOnedollarId(Integer.valueOf(onedollarid));
				showEntity.setGoodsId(onedollarEntity.getGoodsId());
				TGoodsEntity goods = goodsDao.get(onedollarEntity.getGoodsId());
				showEntity.setGoodsName(goods==null?"用户晒单":goods.getGoodsName());
				showEntity.setType(onedollarEntity.getType());
				if(goods!=null){
					showEntity.setPrice(goods.getDefaultPrice());
				}
			}else{
				return JsonChangeUtil.setResultJson(ErrorCode.NOTAUTHORIZED, "该一元抢单活动失效！").getResultMap();
			}
		}
		TOrderInfoEntity order = orderDao.get(Integer.valueOf(orderid));
		if(order==null){
			return JsonChangeUtil.setResultJson(ErrorCode.NOTAUTHORIZED, "这种订单不能晒单哟！").getResultMap();
		}
		if(order.getShowStatus()!=null&&order.getShowStatus()>2){
			return JsonChangeUtil.setResultJson(ErrorCode.NOTAUTHORIZED, "你已经晒了单了哟！").getResultMap();
		}
		TGoodsEntity goods;
		Map<String, Object> p = new HashMap<String, Object>();
		p.put("orderId", Integer.valueOf(order.getOrderId()));
		List<TOrderGoodsEntity> goodsEntity = orderGoodsDao.find(p);
		if(goodsEntity==null||goodsEntity.isEmpty()){
			if(goodsid==null||goodsid.isEmpty()){
				return JsonChangeUtil.setResultJson(ErrorCode.NOTAUTHORIZED, "这种订单不能晒单哟！").getResultMap();
			}
			goods = goodsDao.get(Integer.valueOf(goodsid));
			showEntity.setPrice(goods.getDefaultPrice());
		}else{
			TOrderGoodsEntity g = goodsEntity.get(0);
			goods = goodsDao.get(Integer.valueOf(g.getGoodsId()));
			if(goods==null){
				return JsonChangeUtil.setResultJson(ErrorCode.NOTAUTHORIZED, "这种订单不能晒单哟！").getResultMap();
			}
			showEntity.setPrice(g.getMarketPrice());
		}
		showEntity.setGoodsId(goods.getGoodsId());




		order.setShowStatus((order.getShowStatus()==null?0:order.getShowStatus()) + 1);
		showEntity.setOrderId(Integer.valueOf(orderid));
		if(order.getOnedollarId()!=null){
			showEntity.setOnedollarId(order.getOnedollarId());

			// GoodsOneDollarVO
			GoodsOneDollarVO goods_orange = oneDorllarGoodsDao.query(Integer.valueOf(userid==null||userid.length()==0?"0":userid), Integer.valueOf(order.getOnedollarId()));
			System.out.println("goods_orange   "+goods_orange.getName());
			showEntity.setGoodsName(goods_orange.getName());//
		}else{
			showEntity.setGoodsName(goods.getGoodsName());// 需要先判断是普通商品，还是一元购,以下是普通商品的操作
		}
		orderDao.update(order);
		goodsShowDao.create(showEntity);
		return resultJson.getResultMap();
	}

	@Override
	public Map<String, Object> getMainCat(Map<String, String> filter) {
		Map<String, Object> param = new HashMap<String, Object>();
		param.put("level", Integer.valueOf(1));
		Map<String, Object> sort = new HashMap<String, Object>();
		sort.put("sortOrder", "asc");
		return JsonChangeUtil.setResultJSONList(goodsCatDao.find(param,sort)).getResultMap();
	}

	@Override
	public Map<String, Object> getCat(Map<String, String> filter) {
		String cat = filter.get("cat");
		Map<String, Object> param = new HashMap<String, Object>();
		param.put("parentId", Integer.valueOf(cat));
		Map<String, Object> sort = new HashMap<String, Object>();
		sort.put("sortOrder", "asc");
		return JsonChangeUtil.setResultJSONList(goodsCatDao.find(param, sort)).getResultMap();
	}

	@Override
	public Map<String, Object> getOneDollarJoin(Map<String, String> filter) {
		String id = filter.get("id");
		String pageIndex = filter.get("pageindex");
		String pageSize = filter.get("pagesize");

		int index = 1;
		int size = 10;
		if(pageIndex!=null&&pageIndex.length()!=0){
			index = Integer.valueOf(pageIndex);
			if(index<1){
				index = 1;
			}
		}
		if(pageSize!=null&&pageSize.length()!=0){
			size = Integer.valueOf(pageSize);
			if(size==0){
				size = 10;
			}
		}

		Page page = orderOneDollarUserDao.queryForPage(index, size, Integer.valueOf(id));
		return JsonChangeUtil.setResultJson(page).getResultMap();
	}

	@Override
	public Map<String, Object> updateShowLike(Map<String, String> filter) {
		String userid = filter.get("userid");
		String showid = filter.get("showid");

		synchronized (this){

			if(goodsShowLikeDao.isLiked(Integer.valueOf(userid), Integer.valueOf(showid))){
				return JsonChangeUtil.setResultJson(ErrorCode.INVALID, "您已经点过赞了").getResultMap();
			}

			TGoodsShowEntity showEntity = goodsShowDao.get(Integer.valueOf(showid));
			showEntity.setLikes(showEntity.getLikes()==null?1:(showEntity.getLikes()+1));

			goodsShowDao.update(showEntity);

			TGoodsShowLikeEntity e = new TGoodsShowLikeEntity();
			e.setCreatetime(new Timestamp(System.currentTimeMillis()));
			e.setShowId(Integer.valueOf(showid));
			e.setUserId(Integer.valueOf(userid));
			goodsShowLikeDao.create(e);
			return JsonChangeUtil.setResultJson(showEntity).getResultMap();
		}
	}

	@Override
	public Map<String, Object> createShowComment(Map<String, String> filter) {
		String userid = filter.get("userid");
		String showid = filter.get("showid");
		String content = filter.get("content");

//		if(goodsShowCommentDao.isComment(Integer.valueOf(userid), Integer.valueOf(showid))){
//			return JsonChangeUtil.setResultJson(ErrorCode.NOTAUTHORIZED, "您已经评论过了").getResultMap();
//		}
		if(content==null||content.isEmpty()){
			return JsonChangeUtil.setResultJson(ErrorCode.NOTAUTHORIZED, "你必须说点儿什么呢！").getResultMap();
		}

		TGoodsShowEntity showEntity = goodsShowDao.get(Integer.valueOf(showid));
		showEntity.setComments(showEntity.getComments() == null ? 1 : (showEntity.getComments() + 1));

		goodsShowDao.update(showEntity);

		TGoodsShowCommentEntity e = new TGoodsShowCommentEntity();
		e.setCreatetime(new Timestamp(System.currentTimeMillis()));
		e.setShowId(Integer.valueOf(showid));
		e.setUserId(Integer.valueOf(userid));
		e.setContent(content);
		goodsShowCommentDao.create(e);

		return JsonChangeUtil.setResultJson(showEntity).getResultMap();
	}

	@Override
	public Map<String, Object> getShowCommentList(Map<String, String> filter) {
		String id = filter.get("id");
		String pageIndex = filter.get("pageindex");
		String pageSize = filter.get("pagesize");

		int index = 1;
		int size = 10;
		if(pageIndex!=null&&pageIndex.length()!=0){
			index = Integer.valueOf(pageIndex);
			if(index<1){
				index = 1;
			}
		}
		if(pageSize!=null&&pageSize.length()!=0){
			size = Integer.valueOf(pageSize);
			if(size==0){
				size = 10;
			}
		}

		Page page = goodsShowCommentDao.queryForPage(index, size, Integer.valueOf(id));
		return JsonChangeUtil.setResultJson(page).getResultMap();
	}
}
